﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="RepairOrder.aspx.cs" Inherits="VSM.RepairOrder" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function openMultiItemDialog() {
            var tabid = '<%= Request.QueryString["requestType"] %> ';
            javascript: Main.openCustomDialog('../../ItemPopup.aspx?ItemCategory=' + '102', 600, 610, "");
        }

        function openCustomer() {
            var url = "Popup_Customer.aspx?CustomerCode=S";
            Main.openCustomDialog(url, 650, 410);
        }

        function openVehicle() {
            var url = "Popup_Vehice.aspx?VehicleCode=S";
            Main.openCustomDialog(url, 650, 410);
        }

        function disablePopup(sender, evt) {
            
            var charCode = (evt.which) ? evt.which : event.keyCode;
            if (charCode == 13)
                return true;

            return true;
        }

        function openPopup() {
            var url = "rptViewer.aspx?type=RO";
            Main.openCustomDialog(url, 950, 700);
        }
    </script>
    <div>
        <asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:HiddenField ID="DealerCode" runat="server" />
                <h2>
                    &nbsp;Repair Order</h2>
                <div style="margin-left: 5px; width: 99%;">
                    <hr />

                   <table border="0" width="100%">
                        <tr>
                        <td style="width:50%">
                            <table border="0" width="100%" style="background-color: #D1D4D8;"> 
                                <tr>
                                    <td class="FormLineItemAlt" style="width: 15%">RO No:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="txtRONo" 
                                         runat="server" Width="90%"></asp:TextBox>
                                </td>
                                 <td class="FormLineItemAlt" style="width: 15%">Vehicle ID:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox1" runat="server" Width="70%"></asp:TextBox>
                                     <asp:Button ID="btn_SelectVehicle" runat="server" BackColor="#1B7FC2" ForeColor="#FFFFFF" 
                                         Height="22px" Text="..." Width="18%" OnClientClick="openVehicle();" />
                                </td>
                                </tr>
                                <tr>
                                <td class="FormLineItemAlt" style="width: 15%">Date</td>


                            <td class="FormLineItem" valign="top" style="width:35%"><asp:TextBox ID="txtDate" 
                                    runat="server" AutoPostBack="True" OnTextChanged="txtPODate_TextChanged"></asp:TextBox>
                                 <asp:ImageButton ID="ImageButton1" runat="Server" AlternateText="Click to show calendar"
                                                ImageUrl="~/Images/Calendar_scheduleHS.png" />
                                            <cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtDate"
                                                PopupButtonID="ImageButton1" Format="dd/MM/yyyy">
                                            </cc1:CalendarExtender>

                                            <td class="FormLineItemAlt" style="width: 15%">Reg. No:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox2" runat="server" Width="90%"></asp:TextBox></td>
                            </tr>
                            <tr>
                                <td class="FormLineItemAlt" style="width: 15%">Time In</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox15" runat="server" Width="90%"></asp:TextBox>
                                </td>
                                 <td class="FormLineItemAlt" style="width: 15%">Chassis No:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox3" runat="server" Width="90%"></asp:TextBox></td>
                            </tr>

                            <tr>
                                <td class="FormLineItemAlt" style="width: 15%">Expected Time Out</td>
                                 <td class="FormLineItemAlt" style="width: 35%">
                                     <asp:TextBox ID="TextBox20" runat="server" Width="90%"></asp:TextBox>
                                </td>
                                <td class="FormLineItemAlt" style="width: 15%">Engine No:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox4" runat="server" Width="90%"></asp:TextBox></td>
                            </tr>
                             <tr>
                                <td class="FormLineItemAlt" style="width: 15%">Receptionist:</td>
                                 <td class="FormLineItemAlt" style="width: 35%">
                                     <asp:TextBox ID="TextBox21" runat="server" Width="90%"></asp:TextBox>
                                </td>
                                 <td class="FormLineItemAlt" style="width: 15%">Model:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox5" runat="server" Width="90%"></asp:TextBox></td>
                            </tr>

                            <tr>
                                <td class="FormLineItemAlt" style="width: 15%">Technician</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox17" runat="server" Width="90%"></asp:TextBox></td>
                                <td class="FormLineItemAlt" style="width: 15%">Color:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox6" runat="server" Width="90%"></asp:TextBox></td>
                            </tr>

                             <tr>
                                <td class="FormLineItemAlt" style="width: 15%">Delivery Date:</td>
                                 <td class="FormLineItemAlt" style="width: 35%">
                                     <asp:TextBox ID="txtDate0" runat="server" AutoPostBack="True" 
                                         OnTextChanged="txtPODate_TextChanged"></asp:TextBox>
                                     <cc1:CalendarExtender ID="txtDate0_CalendarExtender" runat="server" 
                                         Format="dd/MM/yyyy" PopupButtonID="ImageButton1" TargetControlID="txtDate0">
                                     </cc1:CalendarExtender>
                                     <asp:ImageButton ID="ImageButton2" runat="Server" 
                                         AlternateText="Click to show calendar" 
                                         ImageUrl="~/Images/Calendar_scheduleHS.png" />
                                 </td>
                                  <td class="FormLineItemAlt" style="width: 15%">Odometer:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox13" runat="server" Width="90%"></asp:TextBox></td>
                            </tr>

                             <tr>
                                <td class="FormLineItemAlt" style="width: 15%">Customer Request:</td>
                                 <td class="FormLineItemAlt" style="width: 35%" rowspan="3"><asp:TextBox ID="TextBox19" 
                                         runat="server" Width="90%" TextMode="MultiLine" Height="72px" ></asp:TextBox></td>
                                         <td class="FormLineItemAlt" style="width: 15%">Customer Name:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox7" runat="server" Width="70%"></asp:TextBox>
                                     <asp:Button ID="btn_SelectCustomer" runat="server" BackColor="#1B7FC2" 
                                         ForeColor="#FFFFFF" Height="22px" Text="..." Width="18%" 
                                         OnClientClick="openCustomer();" />
                                </td>
                            </tr>
                            <tr>
                                 <td class="FormLineItemAlt" style="width: 15%"></td>
                                 <td class="FormLineItemAlt" style="width: 15%">Other Name:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox8" runat="server" Width="90%"></asp:TextBox></td>
                            </tr>
                             <tr>
                                 <td class="FormLineItemAlt" style="width: 15%"></td>
                                  <td class="FormLineItemAlt" style="width: 15%">Address:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox9" runat="server" Width="90%"></asp:TextBox></td>
                            </tr>
                             <tr>
                                 <td class="FormLineItemAlt" style="width: 15%"></td>
                                 <td class="FormLineItemAlt" style="width: 35%"></td>
                                  <td class="FormLineItemAlt" style="width: 15%">Tel:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox10" runat="server" Width="90%"></asp:TextBox></td>
                            </tr>
                             <tr>
                                 <td class="FormLineItemAlt" style="width: 15%"></td>
                                 <td class="FormLineItemAlt" style="width: 35%"></td>
                                 <td class="FormLineItemAlt" style="width: 15%">Tax Code:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox11" runat="server" Width="90%"></asp:TextBox></td>
                            </tr>
                             <tr>
                                 <td class="FormLineItemAlt" style="width: 15%"></td>
                                 <td class="FormLineItemAlt" style="width: 35%"></td>
                                  <td class="FormLineItemAlt" style="width: 15%">Contact Person:</td>
                                 <td class="FormLineItemAlt" style="width: 35%"><asp:TextBox ID="TextBox12" runat="server" Width="90%"></asp:TextBox></td>
                            </tr>
                            </table>

                        </td>
                        
                        </tr>
                   </table>
                   <table border="0" width="100%" style="background-color: #D1D4D8;">
                        <tr>
                            <td  class="FormLineItem">

                                <asp:Button ID="btn_New" runat="server" BackColor="#1B7FC2" 
                                    ForeColor="#FFFFFF" Height="30px" onclick="btn_New_Click" Text="New" 
                                    Width="90px" />
                                <asp:Button ID="btn_AddMultiItems4" runat="server" BackColor="#1B7FC2" 
                                    ForeColor="#FFFFFF" Height="30px" onclick="btn_AddMultiItems_Click" Text="Save" 
                                    Width="90px" />

                                <asp:Button ID="btn_PrintRO" runat="server" BackColor="#1B7FC2" 
                                    ForeColor="#FFFFFF" Height="30px" OnClientClick="openPopup();" Text="Print RO" 
                                    Width="90px" />

                            </td>
                        </tr>

                        <tr>
                            <td class="FormLineItem">
                            
                                <asp:Button ID="btn_LabourAdd" runat="server" BackColor="#1B7FC2" 
                                    ForeColor="#FFFFFF" Height="30px"
                                    Text="Add Labour Charge" Width="130px" />
                            
                            </td>
                        </tr>

                        <tr>
                             <td class="FormLineItem">
                                
                                 <asp:GridView ID="gvLabour" runat="server" AllowPaging="True" 
                                     AllowSorting="True" AutoGenerateColumns="False" BackColor="White" 
                                     BorderColor="White" CellPadding="2" CellSpacing="2" CssClass="GridInner" 
                                     HeaderStyle-Height="27px" HeaderStyle-VerticalAlign="Middle" 
                                     OnRowDeleting="DeleteItem" OnRowUpdating="UpdateItem" Width="100%">
                                     <PagerSettings Mode="NumericFirstLast" />
                                     <PagerStyle BackColor="#70A0D0" Font-Bold="True" HorizontalAlign="Center" 
                                         VerticalAlign="Middle" />
                                     <RowStyle BackColor="#D9E0ED" BorderColor="White" BorderWidth="2px" 
                                         Height="25px" />
                                     <AlternatingRowStyle BackColor="#EEF1F7" BorderColor="White" 
                                         BorderWidth="2px" />
                                     <Columns>
                                         <asp:CommandField HeaderStyle-HorizontalAlign="Center" HeaderText="Action" 
                                             ItemStyle-HorizontalAlign="Center" ItemStyle-Width="70px" 
                                             ShowDeleteButton="True" ShowEditButton="False" Visible="false" />
                                         <asp:TemplateField HeaderText="Action">
                                             <ItemStyle HorizontalAlign="Center" Width="20px" />
                                             <HeaderStyle VerticalAlign="Middle" />
                                             <ItemTemplate>
                                                 <asp:LinkButton ID="lnkDelete0" runat="server" OnClick="lnkDelete_Click" 
                                                     TabIndex="-1" Text="Delete"></asp:LinkButton>
                                             </ItemTemplate>
                                         </asp:TemplateField>
                                         <asp:TemplateField HeaderText="#">
                                             <ItemStyle HorizontalAlign="Center" Width="20px" />
                                             <HeaderStyle VerticalAlign="Middle" />
                                             <ItemTemplate>
                                                 <asp:Label ID="lblNo0" runat="server" BorderStyle="none" Text="">
                                                    </asp:Label>
                                             </ItemTemplate>
                                         </asp:TemplateField>
                                         <asp:TemplateField HeaderText="Position Code">
                                             <ItemStyle HorizontalAlign="Left" Width="100px" />
                                             <HeaderStyle Font-Bold="true" VerticalAlign="Middle" />
                                             <ItemTemplate>
                                                 <asp:TextBox ID="txtItemCode" runat="server" 
                                                     OnKeyPress="return disablePopup(this, event);" OnTextChanged="TextBox_Change" 
                                                     Text='<%# Bind("PositionCode") %>'></asp:TextBox>
                                             </ItemTemplate>
                                         </asp:TemplateField>
                                         <asp:TemplateField HeaderText="Quantity">
                                             <HeaderStyle VerticalAlign="Middle" />
                                             <ItemStyle HorizontalAlign="Center" Width="100px" />
                                             <ItemTemplate>
                                                 <asp:TextBox ID="txtQty0" runat="server" AutoPostBack="true" 
                                                     OnKeyPress="return isNumberKey(this, event);" 
                                                     OnTextChanged="txtOrderQuantity_OnTextChanged" Style="text-align: right" 
                                                     Text='<%# Bind("Quantity") %>' Width="97%" />
                                             </ItemTemplate>
                                         </asp:TemplateField>
                                         <asp:TemplateField HeaderText="Labour Charge">
                                             <ItemStyle HorizontalAlign="Right" />
                                             <HeaderStyle VerticalAlign="Middle" Width="100px" />
                                             <ItemTemplate>
                                                 <asp:TextBox ID="txtDiscount0" runat="server" AutoPostBack="true" 
                                                     OnKeyPress="return isNumberKey(this, event);" 
                                                     OnTextChanged="txtUnitPrice_OnTextChanged" Style="text-align: right" 
                                                     Text='<%# Bind("LabourCharge") %>' />
                                             </ItemTemplate>
                                         </asp:TemplateField>
                                     </Columns>
                                     <HeaderStyle BackColor="#6095C9" Font-Bold="true" Font-Overline="False" 
                                         ForeColor="#ffffff" Height="27px" VerticalAlign="Bottom" />
                                     <EmptyDataTemplate>
                                         <table border="1" cellpadding="2" cellspacing="2" class="GridInner" rules="all" 
                                             style="width: 100%; border-color: White;">
                                             <tr style="height: 27px; color: white; font-weight: bold; text-decoration: none;
                                                    background-color: rgb(96, 149, 201);" valign="middle">
                                                 <th>
                                                     <span>Action</span>
                                                 </th>
                                                 <th>
                                                     <span>#</span>
                                                 </th>
                                                 <th>
                                                     <span>Position Code</span>
                                                 </th>
                                                 <th>
                                                     <span>Quantity</span>
                                                 </th>
                                                 <th>
                                                     <span>Labour Charge</span>
                                                 </th>
                                             </tr>
                                             <tr>
                                                 <td colspan="4">
                                                     <span>No Data</span>
                                                 </td>
                                             </tr>
                                         </table>
                                     </EmptyDataTemplate>
                                 </asp:GridView>
                                
                              </td>
                        </tr>

                        <tr> <td class="FormLineItem">
                        <asp:Button ID="btn_AddMultiItems" Text="Add Part" BackColor="#1B7FC2" 
                                runat="server" ForeColor ="#FFFFFF" Height="30px" Width="90px"  
                                onclick="btn_AddMultiItems_Click"/>
                        </td>
                        </tr>
                   </table>
                    <table border="0" width="100%" style="background-color: #D1D4D8;">
                    
                        <asp:GridView ID="grvPO" CssClass="GridInner" runat="server" Width="100%" BorderColor="White"
                                BackColor="White" AllowSorting="True" AutoGenerateColumns="False" CellPadding="2"
                                HeaderStyle-Height="27px" OnRowCreated="grvPO_RowCreated" CellSpacing="2" OnRowEditing="EditItem"
                                OnRowUpdating="UpdateItem" HeaderStyle-VerticalAlign="Middle" OnRowCancelingEdit="CancelEdit"
                                AllowPaging="True" OnPageIndexChanging="grvSearchResult_PageIndexChanging" PageSize="20"
                                OnRowDeleting="DeleteItem" OnRowDataBound="grvSearchResult_RowDataBound">
                                <PagerSettings Mode="NumericFirstLast" />
                                <PagerStyle BackColor="#70A0D0" Font-Bold="True" HorizontalAlign="Center" VerticalAlign="Middle" />
                                <RowStyle BackColor="#D9E0ED" BorderColor="White" BorderWidth="2px" Height="25px" />
                                <AlternatingRowStyle BackColor="#EEF1F7" BorderColor="White" BorderWidth="2px" />
                                <Columns>
                                    <asp:CommandField HeaderText="Action" ShowDeleteButton="True" ShowEditButton="False"
                                        Visible="false" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                        ItemStyle-Width="70px" />
                                    <asp:TemplateField HeaderText="Action">
                                        <ItemStyle HorizontalAlign="Center" Width="20px" />
                                        <HeaderStyle VerticalAlign="Middle" />
                                        <ItemTemplate>
                                            <asp:LinkButton ID="lnkDelete" runat="server" Text="Delete" TabIndex="-1" OnClick="lnkDelete_Click"></asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="#">
                                        <ItemStyle HorizontalAlign="Center" Width="20px" />
                                        <HeaderStyle VerticalAlign="Middle" />
                                        <ItemTemplate>
                                            <asp:Label ID="lblNo" runat="server" Text="" BorderStyle="none">
                                            </asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Part NBR">
                                        <ItemStyle HorizontalAlign="Left" Width="100px" />
                                        <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                        <ItemTemplate>
                                            <asp:TextBox ID="lblItemCode" runat="server" Text='<%# Bind("ItemCode") %>' OnTextChanged='TextBox_Change' OnKeyPress="return disablePopup(this, event);"></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Part Name">
                                        <ItemStyle HorizontalAlign="Center" Width="250px" />
                                        <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                        <ItemTemplate>
                                            <asp:Label ID="lblItemName" runat="server" Text='<%# Bind("ItemName") %>' BorderStyle="none" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="VN Name">
                                        <HeaderStyle VerticalAlign="Middle" />
                                        <ItemStyle HorizontalAlign="Center" Width="250px" />
                                        <ItemTemplate>
                                            <asp:Label ID="lbFrgnName" runat="server" Text='<%# Bind("FrgnName") %>' BorderStyle="none" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Quantity">
                                        <HeaderStyle VerticalAlign="Middle" />
                                        <ItemStyle HorizontalAlign="Center" Width="50px" />
                                        <ItemTemplate>

                                             <asp:TextBox ID="txtQty" runat="server" Width="97%" Text='<%# Bind("Quantity") %>'
                                                AutoPostBack="true" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right" OnTextChanged="txtOrderQuantity_OnTextChanged"/>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField HeaderText="Price">
                                        <HeaderStyle VerticalAlign="Middle" />
                                        <ItemStyle HorizontalAlign="Center" Width="70px"/>
                                        <ItemTemplate>
                                            <asp:Label ID="lbPrice" runat="server" Text='<%# Bind("Price") %>' BorderStyle="none" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="VAT">
                                        <ItemStyle HorizontalAlign="Right" />
                                        <HeaderStyle VerticalAlign="Middle" Width="70px" />
                                        <ItemTemplate>
                                            <asp:Label ID="lbVat" runat="server" Text='<%# Bind("VAT") %>' BorderStyle="none" />
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField HeaderText="Discount">
                                        <ItemStyle HorizontalAlign="Right" />
                                        <HeaderStyle VerticalAlign="Middle" Width="70px" />
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtDiscount" Width="100%" Style="text-align: right" runat="server" Text='<%# Bind("DiscPrcnt") %>' 
                                                AutoPostBack="true" OnKeyPress="return isNumberKey(this, event);" OnTextChanged="txtUnitPrice_OnTextChanged"/>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField HeaderText="P. Stock">
                                        <ItemStyle HorizontalAlign="Right" />
                                        <HeaderStyle VerticalAlign="Middle" Width="50px" />
                                        <ItemTemplate>
                                            <asp:Label ID="lbStock" runat="server" Text='<%# Bind("Stock") %>' BorderStyle="none" />
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                </Columns>
                                <HeaderStyle BackColor="#6095C9" Font-Bold="true" ForeColor="#ffffff" Font-Overline="False"
                                    Height="27px" VerticalAlign="Bottom" />
                                <EmptyDataTemplate>
                                    <table class="GridInner" style="width: 100%; border-color: White;" border="1" rules="all" cellspacing="2" cellpadding="2">
                                        <tr valign="middle" style="height: 27px; color: white; font-weight: bold; text-decoration: none; background-color: rgb(96, 149, 201);">
                                            <th>
                                                <span>Action</span>
                                            </th>
                                            <th>
                                                <span>#</span>
                                            </th>
                                            <th>
                                                <span>Part NBR</span>
                                            </th>
                                            <th>
                                                <span>Part Name</span>
                                            </th>
                                            <th>
                                                <span>VN Name</span>
                                            </th>
                                            <th>
                                                <span>Quantity</span>
                                            </th>
                                            <th>
                                                <span>Price</span>
                                            </th>
                                            <th>
                                                <span>VAT</span>
                                            </th>
                                            <th>
                                                <span>Discount</span>
                                            </th>
                                            <th>
                                                <span>P. Stock</span>
                                            </th>

                                        </tr>
                                        <tr>
                                            <td colspan="9">
                                                <span>No Data</span>
                                            </td>
                                        </tr>
                                    </table>
                                </EmptyDataTemplate>
                            </asp:GridView>
                    </table>
                </div>
               
                <table width="100%" border="0">
                    <tr>
                        <td>
                            <table style="width: 100%">
                                <tr>
                                    
                                    <td>
                                        <asp:Label ID="lblError" runat="server" Visible="true" Font-Bold="True" ForeColor="Red"></asp:Label>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
